<!--
 * @Author: zhangjingyu
 * @Date: 2020-12-08 09:46:47
 * @LastEditors: zhangjingyu
 * @LastEditTime: 2020-12-12 01:02:13
 * @FilePath: \vprisk10.14\src\components\ca\table\tableColumn.vue
 * @Description: 复杂表格-table列
-->
<template>
  <div>
    <el-table-column
      v-for="(item, i) in unique(tree,'code')"
      :label="item.name"
      :key="i"
      header-align="center"
    >

    <table-column :tree='item.children'></table-column>
    <!-- <template v-if="!item.children" slot-scope="scope">
      <el-input v-model="scope.row[item.code]" :placeholder="scope.columIndex||1"></el-input>
    </template> -->
    </el-table-column>
  </div>
</template>

<script>
export default {
  name: "tableColumn",
  props: {
    tree: {
      type: Array,
      default: () => {
        return [];
      },
    },
     listx: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {};
  },
  mounted(){
  },
  computed: {
    
  },
  methods: {
    // 去重
    unique(arr, attribute) {
      var new_arr = [];
      var json_arr = [];
      for (var i = 0; i < arr.length; i++) {
        // console.log(new_arr.indexOf(arr[i][attribute]));
        if (new_arr.indexOf(arr[i][attribute]) == -1) {
          //  -1代表没有找到
          new_arr.push(arr[i][attribute]); //如果没有找到就把这个name放到arr里面，以便下次循环时用
          json_arr.push(arr[i]);
        } else {
        }
      }
      // return concatArrs(json_arr,j);
      return json_arr;
    },
  },
};
</script>

<style lang="scss" scoped>
</style>